// This script will be injected into Yelp pages
// Main functionality is implemented in background.js via executeScript

console.log('Yelp Scraper content script loaded'); // 添加日志以确认脚本加载

// 立即通知background.js脚本已加载
chrome.runtime.sendMessage({ action: 'contentScriptReady' });

// Listen for messages from background.js
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
  console.log('Content script received message:', message);

  // 默认响应，防止消息挂起
  sendResponse({ success: true });
  return false;
});

// 确保脚本在页面加载完成后运行
if (document.readyState === 'loading') {
  document.addEventListener('DOMContentLoaded', function () {
    console.log('Content script DOM ready');
  });
} else {
  console.log('Content script DOM already ready');
}
